/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package agents.community;

import BESA.ExceptionBESA;
import BESA.Kernell.Agent.Event.EventBESA;
import BESA.Kernell.Agent.GuardBESA;
import BESA.Kernell.System.Directory.AgHandlerBESA;
import co.edu.javeriana.ayllu.agents.communityagent.CommunityAgentState;
import co.edu.javeriana.ayllu.agents.sessionmanageragent.SMA_ReceiveCARequestGuard;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 * Guard to add to a CA that implements synchronous service, it updates its own interface
 * @author Ayllu
 */
public class UpdateSynchInterfaceGuard extends GuardBESA{
    @Override
    public void funcExecGuard(EventBESA ebesa) {
        AgHandlerBESA smaHandler = ((CommunityAgentState)this.getAgent().getState()).getSessionManagerHandler();
        EventBESA event = new EventBESA(SMA_ReceiveCARequestGuard.class.getName(), ebesa.getData());
        try {
            smaHandler.sendEvent(event);
        } catch (ExceptionBESA ex) {
            Logger.getLogger(UpdateSynchInterfaceGuard.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
}
